<?php

class GroupModel extends Model {
	
	protected $name = 'groups';
	
	
	public function create($data) {
		
		$sql = "INSERT INTO groups (name) VALUES ('".$data['name']."')";
		
		$query = mysql_query($sql);
		
		if ($query) {
			return true;
		}
		else {
			die('Error: ' . mysql_error());
		}
		
	}

	public function update($id, $data) {
		
		$sql = "UPDATE " . $this->tableName . " SET name = '" . $data['name'] . "' " .
			   "WHERE id = " . $id;
		
		$query = mysql_query($sql);
		
		if ($query) {
			return true;
		}
		else {
			die('Error: ' . mysql_error());
		}
		
	}
	
	
}
